﻿using BLL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Loginter.车辆调度
{
    public partial class DiaoDuTruck : System.Web.UI.Page
    {
        SchedulingBLL sche = new SchedulingBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetTruckSched();
            }
        }

        /// <summary>
        ///.绑定数据
        /// </summary>
        private void GetTruckSched()
        {
            List<TruckSchedulingMODEL> truck = sche.GetTruckScheduList();
            repter_truck.DataSource = truck;
            repter_truck.DataBind();
        }

        protected void link_diaodu_Click(object sender, EventArgs e)
        {
            CurrenUser carmodel = Session["CurrenUser"] as CurrenUser;
            if (carmodel != null)
            {
                int userid = carmodel.UserID;
                int truckid = Convert.ToInt32(((Button)sender).CommandArgument);
                if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
                {
                    int carriersid = Convert.ToInt32(Request.QueryString["id"]);
                    sche.GetDiaoDuTruck(truckid, carriersid, userid);
                    Response.Write("<script>alert('调度成功！');location.href='TruckDiaoDuGunaLi.aspx'</script>");
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('调度成功！');location.href='TruckDiaoDuGunaLi.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('调度失败！')</script>");
                    //Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('调度失败！')</script>");
                }
            }
        }
    }
}